package com.qianniu.napi.common.util;

import java.io.IOException;
import java.util.regex.Pattern;

/**
 * Created by chenxuebin on 2017/2/26.
 */
public class RegexUtil {

    public static Pattern REGEX_AREA = null;// 地区
    public static Pattern REGEX_DISEASE = null; // 疾病
    public static Pattern REGEX_DISEASE_FEATURE = null;

    public static Pattern REGEX_PRECRIPTION = Pattern.compile("(中成药|中药|方剂|药方|古经方|名方|方子|古方)");
    public static Pattern REGEX_LIQUOR = Pattern.compile("(药酒|酒方)");
    public static Pattern REGEX_GRUEL = Pattern.compile("(粥|养生粥|粥膳|粥方)");
    public static Pattern REGEX_AREA_PREFIX = Pattern.compile("省|市|区|县|镇|旗|盟");
    public static Pattern REGEX_XINGZUO = Pattern.compile("水瓶|双鱼|白羊|金牛|双子|巨蟹|狮子|处女|天秤|天蝎|射手|摩羯");
    public static Pattern REGEX_JIXIONG = Pattern.compile("怎么样|如何|好不好|好坏|预测|评测|评价");
    public static Pattern REGEX_NOT_JOKE = Pattern.compile("讲段|来段|说段|讲|来|说|一个|个|跟|有关|的|搞笑|笑话|段子");
    public static Pattern REGEX_NOT_DAILY = Pattern.compile("看|讲段|来段|段|讲|来|说|一个|个|与|跟|有关|的|简报|日报|快报|早报|新闻|快讯|那条");
    public static Pattern REGEX_NOT_KEYWORD = Pattern.compile("什么|");

    public static Pattern REGEX_DAILY = Pattern.compile("^[0-9]{1,2}、");
    public static Pattern REGEX_NUM = Pattern.compile("^[0-9]{1,2}");


    public static Pattern REGEX_SHOUJIHAO = Pattern.compile("^1[3456789]\\d{9}$");// 手机号正则
    public static Pattern REGEX_SHOUJIHAO_PART = Pattern.compile("^1[3456789]\\d{9}");// 手机号正则，部分匹配

//    public static Pattern REGEX_XINGMING = Pattern.compile("^[\\u4E00-\\u9FA5A-Za-z]+$");//姓名正则
//    public static Pattern REGEX_XINGMING_PART = Pattern.compile("[\\u4E00-\\u9FA5A-Za-z]+");//姓名正则，部分匹配

    public static Pattern REGEX_ZHONGWEN = Pattern.compile("[\\u4E00-\\u9FA5]");// 中文字符
    public static Pattern REGEX_NOT_ZHONGWEN = Pattern.compile("[^\\u4E00-\\u9FA5]");// 非中文字符

    public static Pattern REGEX_TAIL_CHAR = Pattern.compile("[,，;；.。!！?？]");// 非中文字符


    // ============  快递号码正则表达式  ===============
    public static Pattern REGEX_KUAIDI_LHT = Pattern.compile("^[0-9]{9,12}$");            //	联昊通 正则
    public static Pattern REGEX_KUAIDI_QFKD = Pattern.compile("^[0-9]{12}$|^[0-9]{15}$"); //    全峰快递正则
    public static Pattern REGEX_KUAIDI_SCKJ = Pattern.compile("^[0-9]{13}$"); //    四川快捷 正则
    public static Pattern REGEX_KUAIDI_QUANYI = Pattern.compile("^[0-9]{13}$"); //    	全一快递 正则
    public static Pattern REGEX_KUAIDI_BJCS = Pattern.compile("^(CS[0-9]{13})$|^([0-9]{13})$"); //  城市100 正则

//    public static Pattern REGEX_KUAIDI_EMS = Pattern.compile("^[A-Z]{2}[0-9]{9}[A-Z]{2}$"); //	EMS 正则
    public static Pattern REGEX_KUAIDI_EMS = Pattern.compile("^[0-9]{13}$");        //	EMS 正则
    public static Pattern REGEX_KUAIDI_YTO = Pattern.compile("^(0|1|2|3|5|6|7|8|E|D|F|G|V|W|e|d|f|g|v|w)[0-9]{9}$"); //    圆通速递
    public static Pattern REGEX_KUAIDI_ZTO = Pattern.compile("^((618|680|688|618|828|988|118|888|571|518|010|628|205|880|717|718|728|738|761|762|763|701|757)[0-9]{9})$|^((2008|2010|8050|7518)[0-9]{8})$"); //    中通速递 正则
    public static Pattern REGEX_KUAIDI_HZABC = Pattern.compile("^[0-9]{10,11}$"); //   杭州爱彼西 正则
    public static Pattern REGEX_KUAIDI_ZJS = Pattern.compile("^[a-zA-Z0-9]{10}$"); //  宅急送 正则

    public static Pattern REGEX_KUAIDI_YUNDA = Pattern.compile("^[\\s]*[0-9]{13}[\\s]*$"); //	韵达快运 正则
    public static Pattern REGEX_KUAIDI_TTKDEX = Pattern.compile("^[0-9]{14}$"); //    海航天天快递
    public static Pattern REGEX_KUAIDI_BEST = Pattern.compile("^[0-9]{10}$"); //  百世物流 正则
    public static Pattern REGEX_KUAIDI_FEDEX = Pattern.compile("^[0-9]{12}$"); //   联邦快递 正则
    public static Pattern REGEX_KUAIDI_DBL = Pattern.compile("^[0-9]?[0-9]{7}$"); //  德邦物流 正则

    public static Pattern REGEX_KUAIDI_SHQ = Pattern.compile("^[A-Za-z0-9]*[0|2|4|6|8]$"); //	华强物流 正则
    public static Pattern REGEX_KUAIDI_WLB_STARS = Pattern.compile("^TB[0-9]{12}$"); //    海航天天快递
    public static Pattern REGEX_KUAIDI_HTKY = Pattern.compile("^(A|B|C|D|E|H|0)(D|X|[0-9])(A|[0-9])[0-9]{10}$|^(21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39)[0-9]{10}$"); //  汇通快运 正则
    public static Pattern REGEX_KUAIDI_CRE = Pattern.compile("^K[0-9]{13}$"); //   中铁快运 正则
    public static Pattern REGEX_KUAIDI_WLB_ABC = Pattern.compile("^TB[0-9]{12}$"); //  浙江ABC 正则

    public static Pattern REGEX_KUAIDI_SF = Pattern.compile("^[0-9]{12}$"); //		顺丰速运 正则
    public static Pattern REGEX_KUAIDI_CCES = Pattern.compile("^(2|3|5|6|8|5|1)[0-9]{9}$"); // CCES
    public static Pattern REGEX_KUAIDI_STO = Pattern.compile("^(268|888|588|688|368|468|568|668|768|868|968)[0-9]{9}$|^(268|888|588|688|368|468|568|668|768|868|968)[0-9]{10}$|^(STO)[0-9]{10}$"); //  申通E物流 正则
    public static Pattern REGEX_KUAIDI_ZF = Pattern.compile("^CO[A-Z]{2}[0-9]{10}$"); //   	中远 正则
    public static Pattern REGEX_KUAIDI_LB = Pattern.compile("^[0-9]{12}$"); //  龙邦速递 正则

    public static Pattern REGEX_KUAIDI_FAST = Pattern.compile("^[0-9]{11,13}$"); //		快捷速递 正则
    public static Pattern REGEX_KUAIDI_DFH = Pattern.compile("^[0-9]{10}$"); //    	东方汇
    public static Pattern REGEX_KUAIDI_SY = Pattern.compile("^29[0-9]{8}$"); //  首业 正则
    public static Pattern REGEX_KUAIDI_YC = Pattern.compile("^96[0-9]{12}$"); // 	远长 正则
    public static Pattern REGEX_KUAIDI_YCT = Pattern.compile("^[0-9]{12}$"); //  黑猫宅急便 正则

    public static Pattern REGEX_KUAIDI_XB = Pattern.compile("[0-9]{8}"); //		新邦物流 正则
    public static Pattern REGEX_KUAIDI_NEDA = Pattern.compile("^((88|)[0-9]{10})$|^((1|2|3|5|)[0-9]{9})$|^((9|)[0-9]{11})$"); //    港中能达
    public static Pattern REGEX_KUAIDI_UC = Pattern.compile("^VIP[0-9]{9}|V[0-9]{11}|[0-9]{12}$"); //  	优速物流 正则
    public static Pattern REGEX_KUAIDI_QRT = Pattern.compile("^[0-9]{12}$"); //	全日通快递 正则
    // ============ OVER 快递号码正则表达式 OVER ===============


    public static Pattern REGEX_BAIJIAXING = Pattern.compile("蒋|沈|韩|杨|朱|秦|尤|许|何|吕|施|张"
            + "孔|曹|严|华|金|魏|陶|姜|戚|谢|邹|喻"
            + "柏|水|窦|章|云|苏|潘|葛|奚|范|彭|郎"
            + "鲁|韦|昌|马|苗|凤|花|方|俞|任|袁|柳"
            + "酆|鲍|史|唐|费|廉|岑|薛|雷|贺|倪|汤"
            + "滕|殷|罗|毕|郝|邬|安|常|乐|于|时|傅"
            + "皮|卞|齐|康|伍|余|元|卜|顾|孟|平|黄"
            + "和|穆|萧|尹|姚|邵|湛|汪|祁|毛|禹|狄"
            + "米|贝|明|臧|计|伏|成|戴|谈|宋|茅|庞"
            + "熊|纪|舒|屈|项|祝|董|梁|杜|阮|蓝|闵"
            + "席|季|麻|强|贾|路|娄|危|江|童|颜|郭"
            + "梅|盛|林|刁|锺|徐|邱|骆|高|夏|蔡|田"
            + "樊|胡|凌|霍|虞|万|支|柯|昝|管|卢|莫"
            + "经|房|裘|缪|干|解|应|宗|丁|宣|贲|邓"
            + "郁|单|杭|洪|包|诸|左|石|崔|吉|钮|龚"
            + "程|嵇|邢|滑|裴|陆|荣|翁|荀|羊|於|惠"
            + "甄|麴|家|封|芮|羿|储|靳|汲|邴|糜|松"
            + "井|段|富|巫|乌|焦|巴|弓|牧|隗|山|谷"
            + "车|侯|宓|蓬|全|郗|班|仰|秋|仲|伊|宫"
            + "宁|仇|栾|暴|甘|钭|历|戎|祖|武|符|刘"
            + "景|詹|束|龙|叶|幸|司|韶|郜|黎|蓟|溥"
            + "印|宿|白|怀|蒲|邰|从|鄂|索|咸|籍|赖"
            + "卓|蔺|屠|蒙|池|乔|阳|郁|胥|能|苍|双"
            + "闻|莘|党|翟|谭|贡|劳|逄|姬|申|扶|堵"
            + "冉|宰|郦|雍|却|璩|桑|桂|濮|牛|寿|通"
            + "边|扈|燕|冀|僪|浦|尚|农|温|别|庄|晏"
            + "柴|瞿|阎|充|慕|连|茹|习|宦|艾|鱼|容"
            + "向|古|易|慎|戈|廖|庾|终|暨|居|衡|步"
            + "都|耿|满|弘|匡|国|文|寇|广|禄|阙|东"
            + "欧|殳|沃|利|蔚|越|夔|隆|师|巩|厍|聂"
            + "晁|勾|敖|融|冷|訾|辛|阚|那|简|饶|空"
            + "曾|毋|沙|乜|养|鞠|须|丰|巢|关|蒯|相"
            + "查|后|荆|红|游|竺|权|逮|盍|益|桓|公"
            + "万俟|司马|上官|欧阳|夏侯|诸葛|闻人|东方|赫连|皇甫|尉迟|公羊"
            + "澹台|公冶|宗政|濮阳|淳于|单于|太叔|申屠|公孙|仲孙|轩辕|令狐"
            + "钟离|宇文|长孙|慕容|司徒|司空|召|有|舜|叶赫那拉|丛|岳"
            + "寸|贰|皇|侨|彤|竭|端|赫|实|甫|集|象"
            + "翠|狂|辟|典|良|函|芒|苦|其|京|中|夕"
            + "之|章佳|那拉|冠|宾|香|果|依尔根觉罗|依尔觉罗|萨嘛喇|赫舍里|额尔德特"
            + "萨克达|钮祜禄|他塔喇|喜塔腊|讷殷富察|叶赫那兰|库雅喇|瓜尔佳|舒穆禄|爱新觉罗|索绰络|纳喇"
            + "乌雅|范姜|碧鲁|张廖|张简|图门|太史|公叔|乌孙|完颜|马佳|佟佳"
            + "富察|费莫|蹇|称|诺|来|多|繁|戊|朴|回|毓|鉏"
            + "税|荤|靖|绪|愈|硕|牢|买|但|巧|枚|撒"
            + "泰|秘|亥|绍|以|壬|森|斋|释|奕|姒|朋"
            + "求|羽|用|占|真|穰|翦|闾|漆|贵|代|贯"
            + "旁|崇|栋|告|休|褒|谏|锐|皋|闳|在|歧"
            + "禾|示|是|委|钊|频|嬴|呼|大|威|昂|律"
            + "冒|保|系|抄|定|化|莱|校|么|抗|祢|綦"
            + "悟|宏|功|庚|务|敏|捷|拱|兆|丑|丙|畅"
            + "苟|随|类|卯|俟|友|答|乙|允|甲|留|尾"
            + "佼|玄|乘|裔|延|植|环|矫|赛|昔|侍|度"
            + "旷|遇|偶|前|由|咎|塞|敛|受|泷|袭|衅"
            + "叔|圣|御|夫|仆|镇|藩|邸|府|掌|首|员"
            + "焉|戏|可|智|尔|凭|悉|进|笃|厚|仁|业"
            + "肇|资|合|仍|九|衷|哀|刑|俎|仵|圭|夷"
            + "徭|蛮|汗|孛|乾|帖|罕|洛|淦|洋|邶|郸"
            + "郯|邗|邛|剑|虢|隋|蒿|茆|菅|苌|树|桐"
            + "锁|钟|机|盘|铎|斛|玉|线|针|箕|庹|绳"
            + "磨|蒉|瓮|弭|刀|疏|牵|浑|恽|势|世|仝"
            + "同|蚁|止|戢|睢|冼|种|涂|肖|己|泣|潜"
            + "卷|脱|谬|蹉|赧|浮|顿|说|次|错|念|夙"
            + "斯|完|丹|表|聊|源|姓|吾|寻|展|出|不"
            + "户|闭|才|无|书|学|愚|本|性|雪|霜|烟"
            + "寒|少|字|桥|板|斐|独|千|诗|嘉|扬|善"
            + "揭|祈|析|赤|紫|青|柔|刚|奇|拜|佛|陀"
            + "弥|阿|素|长|僧|隐|仙|隽|宇|祭|酒|淡"
            + "塔|琦|闪|始|星|南|天|接|波|碧|速|禚"
            + "腾|潮|镜|似|澄|潭|謇|纵|渠|奈|风|春"
            + "濯|沐|茂|英|兰|檀|藤|枝|检|生|折|登"
            + "驹|骑|貊|虎|肥|鹿|雀|野|禽|飞|节|宜"
            + "鲜|粟|栗|豆|帛|官|布|衣|藏|宝|钞|银"
            + "门|盈|庆|喜|及|普|建|营|巨|望|希|道"
            + "载|声|漫|犁|力|贸|勤|革|改|兴|亓|睦"
            + "修|信|闽|北|守|坚|勇|汉|练|尉|士|旅"
            + "五|令|将|旗|军|行|奉|敬|恭|仪|母|堂"
            + "丘|义|礼|慈|孝|理|伦|卿|问|永|辉|位"
            + "让|尧|依|犹|介|承|市|所|苑|杞|剧|第"
            + "零|谌|招|续|达|忻|六|鄞|战|迟|候|宛"
            + "励|粘|萨|邝|覃|辜|初|楼|城|区|局|台"
            + "原|考|妫|纳|泉|老|清|德|卑|过|麦|曲"
            + "竹|百|福|言|第五|佟|爱|年|笪|谯|哈|墨|连"
            + "南宫|赏|伯|佴|佘|牟|商|西门|东门|左丘|梁丘|琴"
            + "后|况|亢|缑|帅|微生|羊舌|海|归|呼延|南门|东郭"
            + "百里|钦|鄢|汝|法|闫|楚|晋|谷梁|宰父|夹谷|拓跋"
            + "壤驷|乐正|漆雕|公西|巫马|端木|颛孙|子车|督|仉|司寇|亓官|三小"
            + "鲜于|锺离|盖|逯|库|郏|逢|阴|薄|厉|稽|闾丘"
            + "公良|段干|开|光|操|瑞|眭|泥|运|摩|伟|铁|迮");//姓正则，部分匹配

    public static Pattern REGEX_XINGMING = Pattern.compile("^["+REGEX_BAIJIAXING.pattern()+"]{1}[\\u4E00-\\u9FA5]{1,2}");


    public static void main(String[] args) throws IOException {
//        String shouji1 = "13799332211";
//        String shouji2 = "137993322";
//        String jixiong = "w18810370168 3";
////
////        System.out.println("shouji1 match ="+ Const.REGEX_SHOUJIHAO.matcher(shouji1).find());
////        System.out.println("shouji2 match ="+ Const.REGEX_SHOUJIHAO.matcher(shouji2).find());
//        String fff = jixiong.replaceAll("[^0-9]","");
//        Matcher matcher = RegexUtil.REGEX_SHOUJIHAO_PART.matcher(fff);
//        while (matcher.find()) {
//            System.out.println("jixiong =" + matcher.group());
//        }
//
//        String xingming1 = "程工呀";
//        String xingming2 = "2小兵";
//        String xingming3 = "好不好呀";
//        String xingming4 = "好3不_好 呀*的2d（";
//
//        System.out.println("shouji1 match =" + REGEX_XINGMING.matcher(xingming1).find());
//        System.out.println("shouji2 match =" + REGEX_XINGMING.matcher(xingming2).find());
//        System.out.println("shouji2 match =" + REGEX_XINGMING.matcher(xingming3).find());
//
//        System.out.println("xingming4 =" + xingming4.replaceAll("吉凶|的|\\s|_|\\W", ""));
//
//        System.out.println("xingming4 \\W=" + xingming4.replaceAll("\\W+", ""));
//        System.out.println("xingming4 \\w=" + xingming4.replaceAll("\\w", ""));
//        System.out.println("xingming4 \\S=" + xingming4.replaceAll("\\S", ""));
//        System.out.println("xingming4 \\s=" + xingming4.replaceAll("\\s", ""));
//        System.out.println("xingming4 [^0-9]=" + xingming4.replaceAll("[^0-9\\s]", ""));

        System.out.println("白日依山尽".replaceAll(REGEX_ZHONGWEN.pattern(), ""));

        String daily = "1、D大调";
        System.out.println(daily.replaceAll(REGEX_DAILY.pattern(), ""));
        System.out.println("daily match =" + REGEX_DAILY.matcher(daily).find());


    }
}
